﻿Imports BUS
Imports DTO


Public Class MH_TuyChonBaoCaoDSHS

    Private Sub RadioButton1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles rbtTheoLop.CheckedChanged
        If rbtTheoLop.Checked = True Then
            grpLop.Enabled = True
        Else
            grpLop.Enabled = False
        End If
    End Sub

    Private Sub MH_TuyChonBaoCaoDSHS_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim lopBUS As New LopBUS()
        Dim dsLop As New List(Of LopDTO)
        dsLop = lopBUS.LayDanhSach()
        cboLop.DataSource = dsLop
        cboLop.DisplayMember = ("TenLop")
        cboLop.ValueMember = ("MaLop")

        grpLop.Enabled = False
    End Sub

    Private Sub btnLayBC_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLayBC.Click

        If rbtToanTruong.Checked = True Then
            'Khởi tạo báo cáo
            Dim bc As New BC_DanhSachHocSinhToanTruong()
            Dim tbCurrent As CrystalDecisions.CrystalReports.Engine.Table
            Dim tliCurrent As CrystalDecisions.Shared.TableLogOnInfo
            For Each tbCurrent In bc.Database.Tables
                tliCurrent = tbCurrent.LogOnInfo
                With tliCurrent.ConnectionInfo
                    .ServerName = Application.StartupPath + "\0865059_0865125_QuanLiHocSinh.mdb"
                    '.UserID = "" 
                    '.Password = "" 
                    '.DatabaseName = "" 
                End With
                tbCurrent.ApplyLogOnInfo(tliCurrent)
            Next tbCurrent
            'Khởi tạo màn hình hiển thị báo cáo
            Dim mh As New MH_InBaoCao()
            mh.crvBaoCao.ReportSource = bc
            mh.Show()
        End If

        If rbtTheoLop.Checked = True Then
            'Khởi tạo báo cáo
            Dim bc As New BC_DanhSachHocSinhTheoLop()
            Dim tbCurrent As CrystalDecisions.CrystalReports.Engine.Table
            Dim tliCurrent As CrystalDecisions.Shared.TableLogOnInfo
            For Each tbCurrent In bc.Database.Tables
                tliCurrent = tbCurrent.LogOnInfo
                With tliCurrent.ConnectionInfo
                    .ServerName = Application.StartupPath + "\0865059_0865125_QuanLiHocSinh.mdb"
                    '.UserID = "" 
                    '.Password = "" 
                    '.DatabaseName = "" 
                End With
                tbCurrent.ApplyLogOnInfo(tliCurrent)
            Next tbCurrent
            'Truyền tham số vào báo cáo: Mã lớp và tên lớp
            bc.SetParameterValue("Para_MaLop", cboLop.SelectedValue)
            bc.SetParameterValue("Para_TenLop", cboLop.Text.ToUpper)
            'Khởi tạo màn hình hiển thị báo cáo
            Dim mh As New MH_InBaoCao()
            mh.crvBaoCao.ReportSource = bc
            mh.Show()
        End If

        Me.Close()
    End Sub

    Private Sub btnHuy_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnHuy.Click
        Me.Close()
    End Sub
End Class